<?php
$typeArr  = Users::getArrayType();
$typeName = isset($typeArr[$type]) ? $typeArr[$type] : 'User';
?>
<div class="row-fluid">
    <div class="box span12 over-visible">
        <div class="box-header" data-original-title>
            <h2>
                <i class="icon-user"></i><span class="break"></span>
                <?php echo $typeName ?>
            </h2>            
        </div>

        <div class="box-content form-container">
            <div class="row-fluid search-box-user ">
                <div class="pull-left search-input">
                    <?php
                    echo $this->renderPartial('//user/_filter', array(
                        'type' => $type
                    ));
                    ?>
                </div>
                <div class="pull-right">
                    <p class="text-right">
                        <a class="btn btn-success" href="<?php echo Users::getCreateUrl($type); ?>">
                            <i class="icon-plus-sign"></i> New
                        </a>
                        <?php if ($type == Users::TYPE_CUSTOMER): ?>
                            <a class="btn btn-info" href="<?php echo Users::getImportUrl($type); ?>">
                                <i class="icon-upload"></i> Import
                            </a>
                            <?php if ($export_type != FALSE): ?>
                                <a class="btn btn-info" href="<?php echo Users::getExportUrl($type); ?>">
                                    <i class="icon-download"></i> Export
                                </a>
                            <?php endif; ?>
                        <?php endif; ?>
                    </p>
                </div>
            </div>
            <div class="clear"></div>

            <?php if (Yii::app()->user->hasFlash('error')): ?>
                <div class="alert alert-error">
                    <button type="button" class="close" data-dismiss="alert">×</button>
                    <?php echo Yii::app()->user->getFlash('error'); ?>
                </div>
            <?php endif; ?>
            <?php if (Yii::app()->user->hasFlash('success')): ?>
                <div class="alert alert-success">
                    <button type="button" class="close" data-dismiss="alert">×</button>
                    <?php echo Yii::app()->user->getFlash('success'); ?>
                </div>
            <?php endif; ?>   
            <?php
            $key = isset($_GET['key']) ? $_GET['key'] : '';
            if ($key)
            {
                echo "Search results for keyword '<b>$key</b>'";
            }
            ?>   
            <?php
            echo $this->renderPartial('//user/_list', array(
                'data'  => $data,
                'pages' => $pages,
                'type'  => $type,
                'sort'  => $sort,
            ));
            ?>

        </div>
    </div>
</div>
